package org.x4444;

import java.io.IOException;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

public class StringIntPairMapper extends Mapper<LongWritable, Text, Text, IntWritable> {

	Text k = new Text();
	IntWritable v = new IntWritable(1);

	@Override
	protected void map(
			LongWritable key,
			Text value,
			org.apache.hadoop.mapreduce.Mapper<LongWritable, Text, Text, IntWritable>.Context context)
			throws IOException, InterruptedException {
		String vv = value.toString();
		if (vv.trim().length() == 0) {
			return;
		}
		String [] kv = vv.split(",");
		
		k.set(kv[0]);
		int intV = Integer.parseInt(kv[1]);
		v.set(intV);
		context.write(k, v);
	}

}
